using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using Flan.Controls;

public partial class _04_Master_Details : System.Web.UI.Page {

    protected void Page_Load(object sender, EventArgs e) {
        System.Threading.Thread.Sleep(200);
        UpdatePanelPopupExtender.RegisterCloseControl(divClose, UpdatePanel2);
    }

    protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e) {
        //No need to update UpdatePanel1 if the select event fires
        if (e.CommandName != "Select") {
            UpdatePanel1.Update();
        }
        else {
            //Show UpdatePanel2 if the select event fires.
            //We have declared that UpdatePanel2 should refresh when the SelectedIndex for GridView1 changes
            //<asp:AsyncPostBackTrigger ControlID="GridView1" EventName="SelectedIndexChanged"></asp:AsyncPostBackTrigger>
            Control c = e.CommandSource as Control;
            if (c != null) {
                UpdatePanelPopupExtender1.ShowAt(c);
            }
        }
    }

    protected void UpdatePanelPopupExtender1_Close(object sender, EventArgs e)
    {
        GridView1.SelectedIndex = -1;
        DetailsView1.ChangeMode(DetailsViewMode.ReadOnly);
    }
}
